package com.dragon.concurrent.demo.synchornized;

public class TicketWindows implements Runnable {

    private int index = 1;

    private static int MAX = 500;



    @Override
    public void run() {
        while (true) {
            if (index > MAX) {
                break;
            }
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (TicketWindows.class) {
                System.out.println(Thread.currentThread().getName() + "的号码是：" + index++);
            }
        }
    }
}
